package com.mxw.account.errorcode;

import cn.hutool.core.util.StrUtil;
import com.mxw.commons.errorcode.DomainCode;
import com.mxw.commons.errorcode.IErrorCode;

public enum AccountErrorCode implements IErrorCode {
  SERVICE_UNAVAILABLE("000001", "服务忙，请稍后再试", true);

  private String codeId;
  private String msg;
  private boolean whetherDisplay;
  private String domainCode = DomainCode.GATEWAY_SERVICE;

  AccountErrorCode(String codeId, String msg, boolean whetherDisplay) {
    this.codeId = codeId;
    this.msg = msg;
    this.whetherDisplay = whetherDisplay;
  }

  @Override
  public String getCodeId() {
    return this.domainCode + this.codeId;
  }

  @Override
  public String getCodeName() {
    return this.name();
  }

  @Override
  public String getMsg() {
    return this.msg;
  }

  @Override
  public boolean getWhetherDisplay() {
    return this.whetherDisplay;
  }

  @Override
  public String getLogString(String msg) {
    return String.format("%s(%s): %s", getCodeName(), getCodeId(), StrUtil.isBlank(msg) ? getMsg() : msg);
  }

  public String getDomainCode() {
    return this.domainCode;
  }
}
